vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile", "StdinReadPost" }, {
  pattern = { "*.puml" },
  callback = function(args)
    if string.match(args.file, ".puml$") then
      local ft = "plantuml"
      vim.api.nvim_buf_call(args.buf, function()
        vim.api.nvim_cmd({ cmd = "setf", args = { "FALLBACK", ft } }, {})
      end)
    end
  end,
})

vim.api.nvim_create_autocmd({ "BufWritePost" }, {
  pattern = { "*.py" },
  callback = function(ev)
    -- print(string.format("event fired: %s", vim.inspect(ev)))
    -- print "set makeprg=python %"
    vim.o.makeprg = "python %"
  end,
})

-- 设置自动运行 pylint 的钩子
vim.api.nvim_create_augroup("lazy_linters", {
  clear = false,
})
vim.api.nvim_create_autocmd("BufReadPost", {
  pattern = "*.py$",
  group = "lazy_linters",
  callback = function(event)
    require("lazy").run "pylint"
    -- code
    vim.o.foldenable = true
    vim.o.foldmethod = "syntax"
  end,
})
